home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 446 < prev    next >
Internet Message Format  |  1996-08-06  |  3KB

  1. Path: news.crd.ge.com!usenet
  2. From: Christopher R Volpe <volpe@ash.crd.ge.com>
  3. Newsgroups: comp.std.c
  4. Subject: Re: sizeof(char) ~= sizeof(float)
  5. Date: Mon, 26 Feb 1996 10:32:42 -0500
  6. Organization: GE Corporate Research & Development, Schenectady, NY
  7. Message-ID: <3131D29A.7475@ash.crd.ge.com>
  8. References: <WALD.96Feb24131532@woodpecker.lcs.mit.edu>
  9. NNTP-Posting-Host: bart.crd.ge.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
  14.  
  15. David Wald wrote:
  16. [...]
  17. > However, one quirk of this architecture was that not all
  18. > interpretations of a memory word could see all bits.  In particular,
  19. > though integral types and floats each took one word, a float used 8
  20. > more bits than the integral types.  When a word was used in integral
  21. > operations, the lower 8 bits were invisible and harmless.  Thus you
  22. > could have two sections of memory which could be distinguished when
  23. > viewed through float*'s but not when viewed through char*'s.
  24. > Can such an implementation be ANSI-conformant?  The basic argument
  25. > against, presented by Tanmoy Bhattacharya, is that memory compare, and
  26. > possibly memory copy functions, can't be implemented in a portable
  27. > fashion if two dissimilar regions of memory can't be distinguished by
  28. > comparing them char-wise.
  29.  
  30. I don't think this is relevant. At issue here is the behavior of
  31. strictly conforming code presented to the implementation, not the ease,
  32. or even possibility, of implementing the standard library using the
  33. language of the compiler. 
  34.  
  35. The implementation is required to provide a memcmp function that works
  36. as described. If that requires the implementation of memcmp to compare
  37. floats instead of chars, or to use an assembler octet-compare
  38. instruction, then so be it. And it's none of your business whether or
  39. not it does that. 
  40.  
  41. >  (I'm unsure about the memory copy, since
  42. > I've forgotten whether the implementation actually preserved the
  43. > hidden 8 bits when you copied a char.)  Does this violate a constraint
  44. > of the standard?
  45.  
  46. "Constraints" are imposed upon user programs, not compiler
  47. implementations. Though you probably meant "constraint" in the looser
  48. sense, not in the specific ANSI sense. In that case, the one sure-fire
  49. way to demonstrate non-conformance is to present a strictly conforming
  50. program, whose behavior will be clearly discernable by reading the
  51. Standard, that elicits improper output from the compiler in question.
  52. So, can you produce such a program?
  53.  
  54. --
  55.  
  56. Chris Volpe                Phone: (518) 387-7766 (Dial Comm 8*833
  57. GE Corporate R&D            Fax:   (518) 387-6560
  58. PO Box 8, Schenectady, NY 12301        Email: volpecr@crd.ge.com
  59.